package book;

import org.w3c.dom.html.HTMLHeadElement;

//多态
class h{
    String name_h;

    public h(String name_h) {
        this.name_h = name_h;
    }
    public void show() {
        System.out.println("name_h = " + name_h);
    }
}

class hh extends h {
    String name_hh;

    public hh(String name_hh,String name_h) {
        super(name_h);
        this.name_hh = name_hh;
    }

    @Override
    public void show() {
        System.out.println("name_hh = " + name_hh);
    }
}
class hhh extends h{
    String name_hhh;

    public hhh(String name_hhh,String name_h) {
        super(name_h);
        this.name_hhh = name_hhh;
    }

    @Override
    public void show() {
        System.out.println("name_hh = "+name_hhh);
    }
}
class main_run{

    public static void Show(h lei) {
        lei.show();
        if (lei instanceof hh) {
            hh tmp = (hh) lei;
            System.out.println("类hh里的name_hh = "+tmp.name_hh);
        }
        if (lei instanceof hhh) {
            hhh tmp = (hhh) lei;
            System.out.println("类hh里的name_hh = " + tmp.name_hhh);
        }
    }

    public static void main(String[] args) {
        hh HH = new hh("HH", "xixi");
        hhh HHH = new hhh("HHH", "xixi");
        Show(HH);
        Show(HHH);
        h tmp = new hhh("cheshi", "cheshi");
        h tmp1 = (hh) tmp;
        System.out.println(tmp1.name_h);

    }
}

